package com.server.core;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.Socket;
import com.server.http.EmptyRequestException;
import com.server.http.HttpRequest;
import com.server.http.HttpResponse;
import com.server.servlet.Servlet;
import com.server.servlet.ServletContext;

public class ClientHandle implements Runnable{
	
	private Socket socket;
	
	public ClientHandle(Socket socket){
		this.socket = socket;
	}

	public void run() {
		// TODO Auto-generated method stub
		try {
			
			//接受请求
			HttpRequest req = new HttpRequest(socket);
			String reqUri = req.getReqUri();
			
			HttpResponse res = new HttpResponse(socket, reqUri, req);
			res.flush();
			
			
			
			
		} catch (EmptyRequestException e) {
			// TODO Auto-generated catch block
		}finally{
			try {
				socket.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		
		
	}

}
